﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Casemeet.Merchants;
using VK.Comm;
using VK.Casemeet.Lines;
using VK.Comm.TransactSql;
using System.Data;
using VK.Casemeet.Albums;
using VK.Casemeet.TravelLogs;

namespace VK.Casemeet.Web.ShopFront
{
    public partial class Default : System.Web.UI.Page
    {
        public ShopEntity shop = new ShopEntity();

        protected void Page_Load(object sender, EventArgs e)
        {
            int shopID = Util.GetRouteDataInt("ShopID");
            if (shopID != 0)
            {
                shop = ShopBLL.GetShop(shopID);
                (this.Master as Site).shop = shop;
                ShopCard1.shop = shop;
            }

            rptLine.DataSource = LineBLL.GetLineList(1,3, new List<Condition>(){
                new Condition { TableName = "Line", FieldName = "ShopID", ConditionType = ConditionType.NumeralEqual, ConditionValue = shop.ShopID, DbType = DbType.Int32 }
            }, "Line.Created", SortMode.Desc);
            rptLine.DataBind();

            rptAlbum.DataSource = AlbumBLL.GetAlbumList(1, 4, new List<Condition>(){
                new Condition { TableName = "Album", FieldName = "ObjectType", ConditionType = ConditionType.NumeralEqual, ConditionValue = 1, DbType = DbType.Int32 },
                new Condition { TableName = "Album", FieldName = "ObjectID", ConditionType = ConditionType.NumeralEqual, ConditionValue = shop.ShopID, DbType = DbType.Int32 }
            }, null, SortMode.Desc);
            rptAlbum.DataBind();

            rptTravelLog.DataSource = TravelLogBLL.GetTravelLogList(1, 4, new List<Condition>(){
                new Condition { TableName = "TravelLog", FieldName = "ObjectType", ConditionType = ConditionType.NumeralEqual, ConditionValue = 1, DbType = DbType.Int32 },
                new Condition { TableName = "TravelLog", FieldName = "ObjectID", ConditionType = ConditionType.NumeralEqual, ConditionValue = shop.ShopID, DbType = DbType.Int32 },
                new Condition { TableName = "TravelLog", FieldName = "IsEnable", ConditionType = ConditionType.BoolEqual, ConditionValue = true, DbType = DbType.Boolean }
            }, null, SortMode.Desc);
            rptTravelLog.DataBind();


            recomgrouplist.ShopId = shopID;
            recomgrouplist.StartIndex = 1;
            recomgrouplist.EndIndex = 10;
        }
    }
}